<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateSystemNotifyCenter extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('system_notify_center', function (Blueprint $table) {
            $table->id();

            $table->string('title')->default('')->comment('消息标题');
            $table->unsignedTinyInteger('type')->default(0)->comment('所属消息分类 0未选择 1 订货消息 2服务消息 3待办消息 4开店进度');
            $table->unsignedTinyInteger('target')->default(0)
                  ->comment('通知对象 0 未选择 1 店长 2 所有人 3 个人账号');
            $table->unsignedBigInteger('targetId')->index('idx_targetId')->default(0)->comment('消息通知对象个人 RMS用户 id');
            $table->unsignedTinyInteger('isSystem')->default(0)->comment('是否系统生成');
            $table->string('smsTemplate')->default('')->comment('短信模板ID');
            $table->string('pushTitle')->default('')->comment('推送 title');
            $table->string('url')->default('')->comment('推送跳转 URL');
            $table->unsignedTinyInteger('method')->default(1)->comment('推送方式 1 手动 2 自动');
            $table->text('summary')->default('')->comment('弹窗简介');
            $table->text('content')->default('')->comment('消息详情');
            $table->string('autoRules')->default('')->comment('自动推送规则');
            $table->unsignedTinyInteger('isPopup')->default(0)->comment('是否弹窗');
            $table->string('presenceArea')->default('')->comment('页面弹窗区域 1首页 2订货 3我的 4门店 多选 逗号分隔');
            $table->unsignedTinyInteger('status')->default(1)->comment('状态');
            $table->unsignedInteger('sendAt')->index('idx_sendAt')->default(0)->comment('推送时间');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');
            $table->unsignedTinyInteger('isDeleted')->default(0)->comment('是否删除');

            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = '消息中心表';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('system_notify_center');
    }
}
